package br.com.guiav6.sisguia.entity;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "TB_CEP")
public class Cep implements PersistentObject{
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column(name = "ID_CEP")
	private Long id;
	
	@Column(name = "NU_CEP", unique = true, nullable = false)
	private String nuCep;
	
	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = true)
	@JoinColumn(name = "ID_LOGRADOURO")
	private Logradouro logradouro;
	
	@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.LAZY, optional = true)
	@JoinColumn(name = "ID_LOGRADOURO_COMPLEMENTO")
	private LogradouroComplemento logradouroComplemento;
	
	@OneToOne
	@JoinColumn(name = "ID_BAIRRO", nullable = false)
	private Bairro bairro;
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ID_CEP_PAI", insertable = true, updatable = true, nullable = true)
	private Cep cepPai;
	
	@Transient
	private String pathMapa;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNuCep() {
		return nuCep;
	}

	public void setNuCep(String nuCep) {
		this.nuCep = nuCep;
	}

	public Logradouro getLogradouro() {
		return logradouro;
	}

	public void setLogradouro(Logradouro logradouro) {
		this.logradouro = logradouro;
	}

	public LogradouroComplemento getLogradouroComplemento() {
		return logradouroComplemento;
	}

	public void setLogradouroComplemento(LogradouroComplemento logradouroComplemento) {
		this.logradouroComplemento = logradouroComplemento;
	}

	public Bairro getBairro() {
		return bairro;
	}

	public void setBairro(Bairro bairro) {
		this.bairro = bairro;
	}

	public Cep getCepPai() {
		return cepPai;
	}

	public void setCepPai(Cep cepPai) {
		this.cepPai = cepPai;
	}

	public String getPathMapa() {
		return pathMapa;
	}

	public void setPathMapa(String pathMapa) {
		this.pathMapa = pathMapa;
	}

}